package com.guangfeng.yql.comm.netty.util;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

public class TextWebSocketFrameFormatUtil {

    public static JSONObject parse(TextWebSocketFrame text) {
        return JSONUtil.parseObj(text.text());
    }

    public static <T> T parseObject(TextWebSocketFrame text, Class<T> clazz) {
        return JSONUtil.toBean(text.text(), clazz);
    }

    public static String get(TextWebSocketFrame text, String key) {
        return JSONUtil.parseObj(text.text()).getStr(key);
    }
}
